package typistcal.userinterface;

//@author A0096911Y
public class HelpMessage {
	
	private static final String NEWLINE = System.getProperty("line.separator");
	private static final String MESSAGE_HEADER = "Hello! Thank you for using TypistCal!" + NEWLINE
												+ "You can start scheduling with the following commands" + NEWLINE;
	private static final String SEPARATOR = "----------------------------------------------------";
	private static final String MESSAGE_ADD = 	"Add a new entry:" + NEWLINE
												+ "add/..a \t\t[task information]" + NEWLINE 
												+ NEWLINE
												+ "NOTE: You may omit the keyword \"add\" if it is not ambiguous." + NEWLINE;
	private static final String MESSAGE_DELETE = "Delete a task:" + NEWLINE
												+ "delete/del/..d \t[line indices]" + NEWLINE
												+ "\t\t[task keyword]" + NEWLINE 
												+ NEWLINE
												+ "NOTE: You may get the line indices using \"show\" command executes." + NEWLINE;
	private static final String MESSAGE_UPDATE= "Update existing entries:" + NEWLINE
												+ "update/upd/..u \t[line index]   [field to be updated] [new content]" + NEWLINE
												+ "\t\t[line index]   \"completed/done/finished\"" + NEWLINE
												+ "\t\t[line index]   \"to\" [new label]"+ NEWLINE
												+ "\t\t[task keyword] [field to be updated] [new content]" + NEWLINE
												+ "\t\t[task keyword] \"completed/done/finished\"" + NEWLINE
												+ "\t\t[task keyword] \"to\" [new label]"+ NEWLINE;
	private static final String MESSAGE_SHOW = "Show existing tasks:" + NEWLINE
												+ "show/..s/find/..f \t[task keyword]" + NEWLINE
												+ NEWLINE
												+ "NOTE: the keyword may also be the time of the task, all tasks will be shown if no keyword is found." + NEWLINE;
	private static final String MESSAGE_UNDO = "Undo previous command:" + NEWLINE
												+ "undo/.." + NEWLINE
												+ NEWLINE
												+ "NOTE: you can only undo add, delete and update." + NEWLINE;
	private static final String MESSAGE_REDO = "Redo last undo:" + NEWLINE
												+ "redo/..r" + NEWLINE;
	private static final String[][] TABLE_HELP = {{"add", "..a", "Add a new event"},
												  {"delete", "..d", "Delete an event"},
												  {"update", "..u", "Update an event"},
												  {"show", "..s", "Show events"},
												  {"undo", "..", "Undo the previous command (add, delete, update)"},
												  {"redo", "..r", "Redo the previous undo, if possible"}};
	
	private HelpMessage() {}
	
	public static void getHelpMessage(String topic) {
		topic = topic.trim().toLowerCase();
		switch (topic) {
		case "add": case "..a":
			getAddHelpMessage();
			break;
		case "delete": case "del": case "..d":
			getDeleteHelpMessage();
			break;
		case "show": case "..s": case "find": case "..f":
			getShowHelpMessage();
			break;
		case "update": case "..u":
			getUpdateHelpMessage();
			break;
		case "undo": case "..":
			getUndoHelpMessage();
			break;
		case "redo": case "..r":
			getRedoHelpMessage();
			break;
		case "all": default:
			getAllHelpMessage();
		}
	}
	
	private static void getAllHelpMessage() {
		
		UserInterface.displayToDisplayArea(MESSAGE_HEADER);
		UserInterface.displayHelpTable(TABLE_HELP);
		UserInterface.displayToDisplayArea(SEPARATOR);
		UserInterface.displayToDisplayArea("1. " + MESSAGE_ADD + SEPARATOR);
		UserInterface.displayToDisplayArea("2. " + MESSAGE_DELETE + SEPARATOR);
		UserInterface.displayToDisplayArea("3. " + MESSAGE_UPDATE + SEPARATOR);
		UserInterface.displayToDisplayArea("4. " + MESSAGE_SHOW + SEPARATOR);
		UserInterface.displayToDisplayArea("5. " + MESSAGE_UNDO + SEPARATOR);
		UserInterface.displayToDisplayArea("6. " + MESSAGE_REDO);
	}
	
	private static void getAddHelpMessage() {
		UserInterface.displayToDisplayArea(MESSAGE_ADD + NEWLINE);
	}
	
	private static void getDeleteHelpMessage() {
		UserInterface.displayToDisplayArea(MESSAGE_DELETE + NEWLINE);
	}
	
	private static void getUpdateHelpMessage() {
		UserInterface.displayToDisplayArea(MESSAGE_UPDATE + NEWLINE);
	}
	
	private static void getShowHelpMessage() {
		UserInterface.displayToDisplayArea(MESSAGE_SHOW + NEWLINE);
	}
	
	private static void getUndoHelpMessage() {
		UserInterface.displayToDisplayArea(MESSAGE_UNDO + NEWLINE);
	}
	
	private static void getRedoHelpMessage() {
		UserInterface.displayToDisplayArea(MESSAGE_REDO + NEWLINE);
	}
}
